package com.ebelter.myehc.ui.fragments;


import android.os.Bundle;
import android.widget.TextView;

import com.ebelter.btcomlib.bases.fragment.BaseFragment;
import com.ebelter.btcomlib.models.beans.ScaleUser;
import com.ebelter.btcomlib.models.bluetooth.products.three2one.ThreeOneManager;
import com.ebelter.btcomlib.models.bluetooth.products.three2one.bean.ThreeOneMesureResultBean;

import com.ebelter.btcomlib.utils.ViewUtils;

import com.ebelter.btcomlib.views.LevelColorView;
import com.ebelter.myehc.R;
import com.ebelter.myehc.ui.view.CombinView5;
import com.ebelter.myehc.utils.ViewUtilsEHC;

import static com.ebelter.btcomlib.bases.activity.BaseActivity.getString_;


/**
 * 尿酸
 */

public class UA_Fragment extends BaseFragment {
    public static final String TAG = "UA_Fragment";
    @Override
    protected int setLayoutResouceId() {
        return R.layout.fragment_ua;
    }

    private LevelColorView LevelColorView;
    private CombinView5 cb5_ua;

    private TextView activityTopTittleTv;

    public void setActivityTopTittleTv(TextView activityTopTittleTv) {
        this.activityTopTittleTv = activityTopTittleTv;
    }

    @Override
    protected void initView() {
        super.initView();
        FV();

    }

    private void FV() {
        LevelColorView=mRootView.findViewById(R.id.ua_lcv);
        cb5_ua=mRootView.findViewById(R.id.cb5_ua);
    }

    @Override
    protected void initData(Bundle arguments) {
        super.initData(arguments);
        ViewUtilsEHC.setCb5Title2(cb5_ua,N);
    }


    public void setMesureResult(ThreeOneMesureResultBean mesureResult) {
        if (cb5_ua!=null)cb5_ua.setTitle2(((int)mesureResult.mesureValue)+"");
        int result = ThreeOneManager.computerUAHResult(ScaleUser.getUser().getSex(),ScaleUser.getUser().getAge(), (int) mesureResult.mesureValue);

        ViewUtils.displayView(LevelColorView);
        if (LevelColorView!=null)LevelColorView.setLevel(result);


        String resultDes = ThreeOneManager.computerUAResultDesc(result);
        ViewUtils.setTextViewStr(activityTopTittleTv,resultDes);



    }

    public void setMesureResult2Null() {
        if (cb5_ua!=null) cb5_ua.setTitle2(N);
        ViewUtils.goneView(LevelColorView);
        ViewUtils.setTextViewStr(activityTopTittleTv,getString_(R.string.niaosuan));
    }
}
